package com.heart.house.api.common;


import com.heart.house.api.model.User;

/**
 * ThreadLocal 当前线程存放用户信息
 *
 * @author Luo Zhen
 * @create 2019-06-20 15:39
 */
public class UserContext {
    private static final ThreadLocal<User> USER_HOLDER = new ThreadLocal<User>();

    public static void setUser(User user) {
        USER_HOLDER.set(user);
    }

    public static void remove() {
        USER_HOLDER.remove();
    }

    public static User getUser() {
        return USER_HOLDER.get();
    }
}
